<?php

App::uses('Crud', 'Model');

class SurveyFolio extends Crud {

    /**
     * Al Agregar/eliminar/actualizar las constantes de los modelos implica ir
     * y actualizar los comentarios en los campos de la tabla asociada a este modelo.
     */
    const STATUS_ENABLED = 1;
    const STATUS_DISABLED = 0;

    public function getFolio() {
        $filters = array(
            'conditions' => array(
                'status' => self::STATUS_ENABLED,
            ),
            'orden' => array(
                'folio ASC',
            )
        );
        $record = $this->find('first', $filters);
        $folio = $record['SurveyFolio']['folio'];
        $record['SurveyFolio']['status'] = self::STATUS_DISABLED;
        $this->save($record['SurveyFolio']);
        return $folio;
    }

}
